package cn.tedu.hospitalgroupproject.server.content.service.impl;

import cn.tedu.hospitalgroupproject.server.common.pojo.vo.PageData;
import cn.tedu.hospitalgroupproject.server.content.dao.persist.repository.IPatientRepository;
import cn.tedu.hospitalgroupproject.server.content.pojo.entity.Patient;
import cn.tedu.hospitalgroupproject.server.content.pojo.param.PatientAddNewParam;
import cn.tedu.hospitalgroupproject.server.content.pojo.vo.AppointmentListVO;
import cn.tedu.hospitalgroupproject.server.content.pojo.vo.PatientListVO;
import cn.tedu.hospitalgroupproject.server.content.pojo.vo.PatientStandardVO;
import cn.tedu.hospitalgroupproject.server.content.service.IPatientService;
import com.sun.xml.internal.ws.developer.Serialization;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;


/**
 * 处理患者数据的业务实现类
 *
 * @author java@tedu.cn
 * @version 1.0
 */
@Service
@Slf4j
public class PatientServiceImpl implements IPatientService {

    @Value("${hospital-appointment.dao.default-query-page-size}")
    private Integer defaultQueryPageSize;

    @Autowired
   private IPatientRepository patientRepository;

    public PatientServiceImpl() {
        log.info("创建业务对象:PatientServiceImpl");
    }

    @Override
    public void addNew(PatientAddNewParam patientAddNewParam) {
        log.debug("开始处理[新增患者]的业务,参数{}",patientAddNewParam);
        Patient patient=new Patient();
        BeanUtils.copyProperties(patientAddNewParam,patient);

        patientRepository.insert(patient);
    }

    @Override
    public PageData<PatientListVO> list(Integer pageNum) {
        log.debug("开始处理【查询患者列表】业务，页码：{}", pageNum);
        PageData<PatientListVO> pageData = patientRepository.list(pageNum, defaultQueryPageSize);
        return pageData;
    }

    @Override
    public PageData<PatientListVO> list(Integer pageNum, Integer pageSize) {
        log.debug("开始处理【查询患者列表】业务，页码：{}", pageNum);
        PageData<PatientListVO> pageData = patientRepository.list(pageNum, pageSize);
        return pageData;
    }

    @Override
    public PatientStandardVO getStandardById(Long id) {
        return patientRepository.getStandardById(id);
    }
}
